﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FaultBackService.DAL
{
    class Turbine
    {
        /// <summary>
        /// 获取正常的风机序列
        /// </summary>
        /// <returns></returns>
        internal IList<Models.Turbine> GetNormalList()
        {
            using (Models.TurbineFaultContext context = new Models.TurbineFaultContext())
            {
                return context.Turbine
                    .Where(t => t.IsOn == true && t.IsPowerLimited == false && t.IsSelected == true)
                    .ToList();
            }
        }

        /// <summary>
        /// 获取正常的风机ID数组
        /// </summary>
        /// <returns></returns>
        internal int[] GetNormalIds()
        {
            using (Models.TurbineFaultContext context = new Models.TurbineFaultContext())
            {
                return context.Turbine
                    .Where(t => t.IsOn == true && t.IsPowerLimited == false && t.IsSelected == true)
                    .Select(t => t.TurbineId)
                    .ToArray();
            }
        }

        /// <summary>
        /// 获取风机字典
        /// </summary>
        /// <returns></returns>
        internal IDictionary<int, Models.Turbine> GetDict()
        {
            using (Models.TurbineFaultContext context = new Models.TurbineFaultContext())
            {
                return context.Turbine.ToDictionary(t => t.TurbineId);
            }
        }
    }
}
